package io.gitee.duxiuhuan.mailbox.outter;

import io.gitee.duxiuhuan.mailbox.database.entries.MessageInfo;
import io.gitee.duxiuhuan.mailbox.service.impl.MessageManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class MessageManagerUtils {
    
    @Autowired
    private MessageManagerService messageManagerService;
    
    public List<MessageInfo> selectMessage(String tableName, MessageInfo messageInfo) {
        return messageManagerService.selectMessage(tableName, messageInfo);
    }
    
    public Boolean insertMessages(String tableName, List<MessageInfo> messageInfoList) {
        return messageManagerService.insertMessages(tableName, messageInfoList);
    }
    
    public Boolean deleteMessageById(String tableName, Long id) {
        return messageManagerService.deleteMessageById(tableName, id);
    }
    
    public List<MessageInfo> selectMessage(Long tableId, MessageInfo messageInfo) {
        return this.selectMessage("table_" + tableId.toString(), messageInfo);
    }
    
    public Boolean insertMessages(Long tableId, List<MessageInfo> messageInfoList) {
        return this.insertMessages("table_" + tableId.toString(), messageInfoList);
    }
    
    public Boolean deleteMessageById(Long tableId, Long id) {
        return this.deleteMessageById("table_" + tableId.toString(), id);
    }
}
